<!-- 注册会员中心 -->
<template>
  <div>
    <div class="gl_searchBox gl_mb_15">
      <el-row :gutter="20">
        <el-col :md="6" :lg="4">
          <p>姓名</p>
          <el-input v-model="Api_GET_EventsManagementUserRegisterListQO.Filter" placeholder="请输入姓名查询" size="mini" clearable @change="refreshList()" />
        </el-col>
        <el-col :md="6" :lg="4">
          <el-button style="margin-top:26px" type="primary" size="mini" @click="refreshList()">查询</el-button>
          <el-button style="margin-top:26px" type="warning" size="mini" @click="refreshSearchForm()">重置</el-button>
        </el-col>
      </el-row>
    </div>
    <el-table ref="memberTable" v-loading="loading" :data="memberData" size="mini">
      <el-table-column type="index" label="序号" />
      <el-table-column prop="name" label="姓名">
        <template slot-scope="{row}">
          <span>
            {{ row.name ? row.name: '- -' }}
          </span>
        </template>
      </el-table-column>
      <el-table-column prop="phoneNumber" label="登录账号" />
      <el-table-column prop="userTypeCode" label="注册类型">
        <template slot-scope="{row}">
          <span v-for="item in dict.userType" :key="item.code">
            {{ item.code === row.userTypeCode ? item.value: '' }}
          </span>
        </template>
      </el-table-column>
      <el-table-column fixed="right" label="操作" width="300">
        <template slot-scope="{row, $index}">
          <el-button size="mini" type="text" @click="detail($index, row)">查看详情</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-row class="gl_pt_20" style="text-align: center;">
      <el-pagination
        :current-page="Api_GET_EventsManagementUserRegisterListQO.Page"
        :page-size="Api_GET_EventsManagementUserRegisterListQO.MaxResultCount"
        :total="totalPage"
        layout="total,sizes,prev,pager,next,jumper"
        :page-sizes="[10, 20, 50, 100]"
        @size-change="sizeChange"
        @current-change="pageIndexChange"
      />
    </el-row>
  </div>
</template>

<script>
import { Api_GET_EventsManagementUserRegisterListQO } from '@/lib/form/game/swaggerForm';
import { api_GET_EventsManagementUserRegisterList } from '@/extend/api/gameswaggerApi/app.js';
import { mapState, mapActions } from 'vuex';
export default {
  name: 'MemberReview',
  components: {},
  data() {
    return {
      loading: false,
      currentPage: 1,
      totalPage: 0, // 分页总条目数
      Api_GET_EventsManagementUserRegisterListQO: new Api_GET_EventsManagementUserRegisterListQO(), // 搜索所用表单
      memberData: [] // 表格数据
    };
  },
  computed: {
    ...mapState({
      dict: state => state.dict.dict
    })
  },
  created() {
    this.refreshList();
    this.getDict();
  },
  methods: {
    ...mapActions({ getDict: 'dict/getDict' }),
    // 获取表格数据
    refreshList(page) {
      this.loading = true;
      this.Api_GET_EventsManagementUserRegisterListQO.Page = page || 1;
      this.Api_GET_EventsManagementUserRegisterListQO.SkipCount = (this.Api_GET_EventsManagementUserRegisterListQO.Page - 1) * this.Api_GET_EventsManagementUserRegisterListQO.MaxResultCount;
      api_GET_EventsManagementUserRegisterList(this.Api_GET_EventsManagementUserRegisterListQO).then(res => {
        this.memberData = res.items;
        this.totalPage = res.totalCount;
        this.loading = false;
      }).catch(() => {
        this.loading = false;
      });
    },
    // 重置搜索表单
    refreshSearchForm() {
      this.Api_GET_EventsManagementUserRegisterListQO = new Api_GET_EventsManagementUserRegisterListQO();
      this.refreshList();
    },
    // 查看详情
    detail(index, row) {
      if (row.userTypeCode === 'Personal') {
        this.$router.push({
          path: '/member/memberCenter/individual',
          query: { id: row.id, delegationId: row.delegationId }
        });
      } else if (row.userTypeCode === 'Delegation') {
        this.$router.push({
          path: '/member/memberCenter/group',
          query: { id: row.id, delegationId: row.delegationId }
        });
      } else if (row.userTypeCode === 'PersonalDelegation') {
        this.$router.push({
          path: '/member/memberCenter/all',
          query: { id: row.id, delegationId: row.delegationId }
        });
      }
    },
    // 分页
    sizeChange: function(MaxResultCount) {
      this.Api_GET_EventsManagementUserRegisterListQO.MaxResultCount = MaxResultCount;
      this.refreshList();
    },
    pageIndexChange(currentPage) {
      this.refreshList(currentPage);
    }
  }
};
</script>
<style lang="scss" scoped>
</style>
